﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 限制Tips的大小,用于修复Tips出现以后Z值会变成一个奇怪的值
/// 并且缩放比例会异常的情况
/// 
/// 使用的是项目里Tips那一套
/// 这个组件挂在TipsEquipment上
/// </summary>
public class CommanderFixedTips : MonoBehaviour
{
    RectTransform rectTransform;
    /// <summary>
    /// 限制最大的缩放大小
    /// </summary>
    public float maxScale=1.0f;
    // Start is called before the first frame update
    void Start()
    {
        rectTransform = transform as RectTransform;
    }

    // Update is called once per frame
    void Update()
    {
        //限制z必须为0
        if (rectTransform.position.z != 0) rectTransform.position = new Vector3(rectTransform.position.x, rectTransform.position.y,0);

        //限制缩放在maxScale之内
        if(rectTransform.localScale.x > 1)
        {
            rectTransform.localScale = new Vector3(maxScale,maxScale,1);
        }

    }
}
